var ctxPath = "/education";

$(function () {
    var page = 0;
    var count = -1;
    var dropload = $('.page-load').dropload({
        scrollArea: window,
        domDown: {
            domClass: 'dropload-down',
            domRefresh: '<div class="dropload-refresh">上拉加载更多</div>',
            domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
            domNoData: '<div class="dropload-noData">已无数据</div>'
        },
        loadDownFn: function (me) {
            setTimeout(function () {
                page++;

                if ($('.page-pane a').length == count) {
                    me.resetload();
                    me.lock();
                    me.noData();
                    me.resetload();
                    return;
                }

                $.ajax({
                    url: ctxPath + '/wx/api/pointReward/queryProducts',
                    type: 'post',
                    dataType: 'json',
                    data: {page: page, limit: 4},
                    success: function (result) {
                        if(result.returnCode == 0) {
                            var prProducts = result.data;

                            count = result.count;
                            var result = '';
                            $(prProducts).each(function (index, ele) {
                                result += ''
                                    + '<a class="list-item" href="/education/wx/integralDetail.html?id=' + ele.id + '">'
                                    + '<div  class="list-img"> '
                                    + '<img src="' + ele.showImage + '">'
                                    + '</div>'
                                    + '<div class="list-mes">'
                                    + '<h3 class="list-title">' + ele.name + '</h3>'
                                    + '<div class="list-mes-item">  '
                                    + '<span class="list-price"><em>¥</em>' + ele.price + '</span>'
                                    + '</div>'
                                    + '</div>'
                                    + '</a>';
                            })

                            $('.page-pane').eq(0).append(result);
                            me.resetload();
                        } else {
                            alert(result.returnMsg);
                        }
                    }
                });



                // for (var index = 0; index <10; index++) {
                //
                //
                //     // }
                // }

            }, 500);
        }
    });

});